Code
## need cleaning
socio_demo_dta |>
mutate(degree = str_remove_all(degree, "[0-9]|-")) |>
mutate(degree = str_trim(degree, side = "both")) |>
count(degree, sort = T) |>
View()ViSERDAC
January 30, 2026
## plot subtitle
plt_subtitle <- str_wrap("Entertainment, music, and lifestyle content were the most engaged categories among female students, while males showed stronger engagement with entertainment, music, and gaming; overall, females reported higher engagement across most content types.", 120)
plt_soc_med_content_gender <-
soc_med_content_dta |>
# filter(!str_detect( social_media, "All of it")) |>
count(sex, social_media_content) |>
group_by(sex) |>
mutate(pct = n / sum(n)) |>
mutate(social_media_content = reorder_within(social_media_content, pct, sex)) |>
mutate(pct_label = str_c("n=", n, " (", round(pct*100, ), "%)")) |>
ggplot(aes(pct, social_media_content, fill = sex)) +
geom_col(width = 0.8) +
geom_text(aes(label = pct_label), hjust = -0.1) +
scale_x_continuous(limits = c(0, 0.3), labels = scales::percent_format()) +
scale_y_reordered() +
facet_wrap(~ sex, scales = "free", ncol = 2) +
custom_theme +
labs(
title = "What kinds of content do you usually engage with on social media?",
subtitle = plt_subtitle,
x = element_blank(),
y = element_blank(),
fill = element_blank()
)
## saving plot
ggsave(
plot = plt_soc_med_content_gender,
filename = "plot/soc_med_content_gender.jpg",
unit = "in",
height = 6,
width = 12,
dpi = 400
)
## display plot
knitr::include_graphics("plot/soc_med_content_gender.jpg")## subtitle
plt_subtitle <- str_wrap("Across platforms, entertainment, music, and lifestyle content consistently drew the highest engagement, with Facebook, Instagram, TikTok, and YouTube showing similar patterns; educational and news content also ranked strongly, while politics and gaming remained lower overall.", 120)
plt_soc_med_content <-
soc_med_content_dta |>
filter(!str_detect( social_media, "All of it")) |>
count(social_media, social_media_content) |>
group_by(social_media) |>
mutate(pct = n / sum(n)) |>
mutate(social_media_content = reorder_within(social_media_content, pct, social_media)) |>
mutate(pct_label = str_c("n=", n, " (", round(pct*100, ), "%)")) |>
ggplot(aes(pct, social_media_content)) +
geom_col(width = 0.8) +
geom_text(aes(label = pct_label), hjust = -0.1) +
scale_x_continuous(limits = c(0, 0.3), labels = scales::percent_format()) +
scale_y_reordered() +
facet_wrap(~ social_media, scales = "free", ncol = 2) +
custom_theme +
labs(
title = "What kinds of content do you usually engage with on social media?",
subtitle = plt_subtitle,
x = element_blank(),
y = element_blank()
)
## saving plot
ggsave(
plot = plt_soc_med_content,
filename = "plot/soc_med_content.jpg",
unit = "in",
height = 14,
width = 12,
dpi = 400
)
## display plot
knitr::include_graphics("plot/soc_med_content.jpg")soc_med_category |>
filter(!str_detect( social_media, "All of it")) |>
count(social_media, social_media_hours) |>
group_by(social_media) |>
mutate(pct = n / sum(n)) |>
mutate(social_media_hours = reorder_within(social_media_hours, pct, social_media)) |>
mutate(pct_label = str_c("n=", n, " (", round(pct*100, ), "%)")) |>
ggplot(aes(pct, social_media_hours)) +
geom_col(width = 0.8, position = position_dodge2(preserve = "single")) +
geom_text(aes(label = pct_label), hjust = -0.1) +
scale_x_continuous(limits = c(0, 1), labels = scales::percent_format()) +
scale_y_reordered() +
facet_wrap(~ social_media, scales = "free", ncol = 2) +
custom_theme +
labs(
title = "What kinds of content do you usually engage with on social media?",
x = element_blank(),
y = element_blank()
)
1.2 Social Media
1.2.1 Platform
Code